<template>
  <el-card>
    <el-button type="primary" @click="toAdd">添加商品</el-button>
    <el-table :data="goodsList" style="width: 100%">
      <el-table-column label="日期" width="180">
        <template slot-scope="scope">
          {{ scope.row.add_time | dataFormat }}
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      queryInfo: {
        query: '', // 查询参数
        pagenum: 1, // 当前页码
        pagesize: 10 // 每页显示条数
      },
      goodsList: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    toAdd() {
      this.$router.push('/goods/add')
    },
    getList() {
      this.$http
        .get('goods', {
          params: this.queryInfo
        })
        .then((res) => {
          this.goodsList = res.data.data.goods
        })
    }
  }
}
</script>

<style scoped>
</style>
